﻿/***************************************************************************
 创建者: 华磊
 开始时间: 2019.9.20
 copyright: (C) 华友高科
 修改说明: (每次有修改就添加一条，带有 修改人，修改时间，修改描述)
 example (1) 姓名 2019.9.20 类的具体实现代码编写

 ***************************************************************************
 *  @file x.h
 *  功能:
 *
 *
 ***************************************************************************/
#ifndef MAPEDITWINDOW_H
#define MAPEDITWINDOW_H

#include <QtWidgets>
#include <QMainWindow>
#include "onemap.h"

class DockView;
class DockMapTree;
class DockProperty;
class DockBlock;
class DockGroup;
class MapFileParse;
class CommunicateNormalDelegate;
class GlobalData;
class MapStationEditView;
class PathEditView;
class MapMergeView;

class MapEditWindow : public QMainWindow
{
    Q_OBJECT
public:
    explicit MapEditWindow(CommunicateNormalDelegate *communicateNormalIn,GlobalData *globalDataIn,
                           OneMap *_oneMap,QWidget *parent = nullptr);
    ~MapEditWindow();
    void init();
signals:
    void sig_setTool(int);

    void sig_setSelectSelect();
    void sig_setSelectHand();
    void sig_displayAll();
    void sig_repaint();

    void sig_addBkg(int _bkg);
    void sig_propertyChanged(MapSpirit *spirit);
public slots:

    void loginControllerSucess_slot();
//    void controllerLogin_slot(QVector<int> controllerIpAddress,QVector<int> hmiIpAddress,
//                              QString port,QString passwardString,int selectedAccount);

    void updateMapShow_slot();
    void slot_chooseSpirit(MapSpirit* spiritIn);

    void about();
    void aboutHY();

    void onServerConnect();
    void onServerDisconnect();
    void onServerConnectting();

    void onSendFail();
    void onWaitResponseTimeOut();
    void onTip(QString s);
    void onErr(int errcode,QString info);
    void onNewRequest();

    void slot_load_map_success();
    void slot_set_map_success();

    void slot_currentMousePos(QPointF pos);

    void slot_cancelTool();

    //几个action
    void on_toolErase_triggered(bool b);
    void on_toolStationDraw_triggered(bool b);
    void on_toolStationReport_triggered(bool b);
    void on_toolStationHalt_triggered(bool b);
    void on_toolStationCharge_triggered(bool b);
    void on_toolStationLoad_triggered(bool b);
    void on_toolStationUnload_triggered(bool b);
    void on_toolStationLoadUnload_triggered(bool b);
    void on_toolStationOrigin_triggered(bool b);
    void on_toolLine_triggered(bool b);
    void on_toolQb_triggered(bool b);
    void on_toolCb_triggered(bool b);
    void on_addBkgd_triggered(bool b);
    void on_recordStationPosition_triggered(bool b);//载入点位置
    void on_selectSelect_triggered(bool b);
    void on_selectHand_triggered(bool b);
    void on_displayAll_triggered(bool b);
    void on_displayItemRatioIncrease_triggered(bool b);
    void on_displayItemRatioDecrease_triggered(bool b);
    void on_toolSave_triggered(bool b);
    void on_toolLoad_triggered(bool b);
    void on_toolCreateMap_triggered(bool b);
    void on_toolEditStation_triggered(bool b);
    void on_toolEditPath_triggered(bool b);
    void on_toolRestoreBeforeMap_triggered(bool b);
    void on_toolMergeMap_triggered(bool b);

protected:
        void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
private:
    void recordStationPositionOnce();//载入点位置
    int createNewMap();

    void createActions();
    void createStatusBar();

    //状态栏改变
    void statusbar_info(QString msg);
    void statusbar_err(QString msg);
    void statusbar_pos(QString msg);

private:

    MapFileParse *mapfileParser;

    QLabel *info_label;
    QLabel *error_label;

    QLabel *pos_label;

    OneMap *oneMap;//地图编辑器的一个map
    OneMap *lastoneMap;//地图编辑器的一个map

    DockMapTree *dockMapTree;//地图节点tree
    DockProperty *dockProperty;//节点属性
    DockView *dockView;//地图视图
    DockBlock *blockView;
    DockGroup *groupView;

    QAction *selectSelect;
    QAction *selectHand;
    QAction *selectDisplayAll;
    QAction *selectDisplayItemRatioIncrease;
    QAction *selectDisplayItemRatioDecrease;
    QAction *toolRestoreBeforeMap;

    QAction *toolErase;
    QAction *toolStationDraw;
    QAction *toolStationReport;
    QAction *toolStationHalt;
    QAction *toolStationCharge;
    QAction *toolStationLoad;
    QAction *toolStationUnload;
    QAction *toolStationLoadUnload;
    QAction *toolStationOrigin;
    QAction *toolLine;
    QAction *toolQb;
    QAction *toolCb;

    QAction *toolCreateMap;
    QAction *toolSave;
    QAction *toolLoad;
    QAction *toolEditStation;
    QAction *toolEditPath;
    QAction *toolMergeMap;



    QAction *addBkgd;
    QAction *recordStationPosition;
    CommunicateNormalDelegate *communicateNormal;
    GlobalData *globalData;
    MapSpirit* choosedSpirit;
    MapStationEditView *mapStationEditView;
    PathEditView *pathEditView;
    MapMergeView *mapMergeView;
};

#endif // MAPEDITWINDOW_H
